package it.lovaex.scb;

import it.lovaex.scb.Cart.Cart;
import it.lovaex.scb.factory.DiscountRateFactory;
import it.lovaex.scb.factory.IDiscountRateFactory;
import it.lovaex.scb.model.BookItem;
import it.lovaex.scb.model.GroceryItem;
import it.lovaex.scb.model.IItem;
import it.lovaex.scb.model.Item;

import java.math.BigDecimal;
import java.util.ArrayList;

public class ShoppingCart {

	public static BigDecimal threshold = new BigDecimal(40);
	public static BigDecimal additionalRate = new BigDecimal(0.05);
	
	public static void main(String[] args){
		//prepare the use cases
		/*
		 *	
		    Input 1:
			1 Pasta 1kg at 4.29
			1 Book at 10.12
		 
		 	Input 2:
			1 Coffee 500g at 3.21
			1 Pasta 1Kg at 4.29
			1 Cake at 2.35
			
			Input 3:
			10 Chocolate at 2.1
			1 Wine at 10.5
			1 Book at 15.05
			5 Apple at 0.5 
		 * 
		 */
		ArrayList<IItem> uc1 = new ArrayList<IItem>();
		uc1.add(new GroceryItem("Pasta 1kg  ", BigDecimal.valueOf(4.29)));
		uc1.add(new BookItem("Book       ", BigDecimal.valueOf(10.12)));
		
		ArrayList<IItem> uc2 = new ArrayList<IItem>();
		uc2.add(new GroceryItem("Coffee 500g", BigDecimal.valueOf(3.21)));
		uc2.add(new GroceryItem("Pasta 1kg  ", BigDecimal.valueOf(4.29)));
		uc2.add(new Item("Cake       ", BigDecimal.valueOf(2.35)));
		
		ArrayList<IItem> uc3 = new ArrayList<IItem>();
		uc3.add(new Item("Chocolate  ", BigDecimal.valueOf(2.1)));
		uc3.add(new Item("Chocolate  ", BigDecimal.valueOf(2.1)));
		uc3.add(new Item("Chocolate  ", BigDecimal.valueOf(2.1)));
		uc3.add(new Item("Chocolate  ", BigDecimal.valueOf(2.1)));
		uc3.add(new Item("Chocolate  ", BigDecimal.valueOf(2.1)));
		uc3.add(new Item("Chocolate  ", BigDecimal.valueOf(2.1)));
		uc3.add(new Item("Chocolate  ", BigDecimal.valueOf(2.1)));
		uc3.add(new Item("Chocolate  ", BigDecimal.valueOf(2.1)));
		uc3.add(new Item("Chocolate  ", BigDecimal.valueOf(2.1)));
		uc3.add(new Item("Chocolate  ", BigDecimal.valueOf(2.1)));
		uc3.add(new Item("Wine       ", BigDecimal.valueOf(10.5)));
		uc3.add(new BookItem("Book       ",  BigDecimal.valueOf(15.05)));
		uc3.add(new Item("Apple      ", BigDecimal.valueOf(0.5)));
		uc3.add(new Item("Apple      ", BigDecimal.valueOf(0.5)));
		uc3.add(new Item("Apple      ", BigDecimal.valueOf(0.5)));
		uc3.add(new Item("Apple      ", BigDecimal.valueOf(0.5)));
		uc3.add(new Item("Apple      ", BigDecimal.valueOf(0.5)));
		
		IDiscountRateFactory discountFactory = new DiscountRateFactory();
		Cart cart = new Cart(discountFactory);
		
		// UC1
		for (IItem item : uc1) {
			cart.add(1, item);
		}
		
		System.out.println("uc1 : \n" + cart.getReceipt());
		cart.empty();
		
		// UC2
		for (IItem item : uc2) {
			cart.add(1, item);
		}
		
		System.out.println("\n\nuc2 : \n" + cart.getReceipt());
		cart.empty();
		
		// UC3
		for (IItem item : uc3) {
			cart.add(1, item);
		}
		
		System.out.println("\n\nuc3 : \n" + cart.getReceipt());
		cart.empty();
		
		// UC3, second mode
		cart.add(10, new Item("Chocolate  ", BigDecimal.valueOf(2.1)));
		cart.add(1, new Item("Wine       ", BigDecimal.valueOf(10.5)));
		cart.add(1, new BookItem("Book       ", BigDecimal.valueOf(15.05)));
		cart.add(5, new Item("Apple      ", BigDecimal.valueOf(0.5)));
		
		System.out.println("\n\nuc3  : \n" + cart.getReceipt());
	}
}
